package com.example.service.serviceImpl;

import com.example.constants.Constants;
import com.example.mapper.CommandMapper;
import com.example.pojo.CommandParams;
import com.example.service.CommandService;
import com.example.utils.ProductCommandIssued;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
public class CommandServiceImpl implements CommandService {
    @Autowired
    CommandMapper commandMapper;

    /**
     * 命令下发
     */
    @Override
    public void sendCommand(String token, CommandParams commandParams) throws Exception {
        ProductCommandIssued.issueCommandByToken(Constants.PROJECT_ID, Constants.DEVICE_ID,
                                                 commandParams.getCommandName(), Constants.SERVICE_ID,
                                                 new HashMap<>(Map.of(commandParams.getParaName(),
                                                 commandParams.getParaValue())), token);
    }
}
